﻿using System;
using System.Collections.Generic;
using System.Collections.ObjectModel;
using System.Net.Http;
using System.Web;
using System.Web.Http;
using Microsoft.AspNet.Identity;
using RealtReview.DataAccess.Entities;
using RealtyReview.Business.Models.Review;
using RealtyReview.Business.Models.ViewModels;

namespace RealtyReview.Controllers.ApiControllers
{
    public class DataController : ApiController
    {
        [ActionName("cities")]
        public IEnumerable<string> GetCities()
        {
            var content = Request.GetRequestContext();
            var id = content.Principal.Identity.GetUserId();
            return new Collection<string>(new Collection<string> { "Минск", "Москва", "Коссово", "Столбцы" });
        }

        [ActionName("messages")]
        public IEnumerable<MessageViewModel> GetMessages(int page)
        {
            object htpC;
            HttpContext htp;
            Request.Properties.TryGetValue("MS_HttpContext", out htpC);

            var model = new List<MessageViewModel> { 
                    new MessageViewModel
                    {
                        From = "Петя",
                        To = "Вася",
                        Message = page + "Входящее 1csfg sfg sfg sdf gsdfg sdfg sdfg d",
                        Title = "Заголовок 1",
                        DateCreated = DateTime.Now
                    },
                    new MessageViewModel
                    {
                        From = "Вася",
                        To = "Петя",
                        Message = page + "Входящее 2 csfg сообщение csfg sfg sdf gsdfg sdfg sdfg d",
                        Title = "Заголовок 2",
                        DateCreated = DateTime.Now
                    },
                    new MessageViewModel
					{
						From = "Петя",
                        To = "Вася",
						Message = page + "Исходящее 1 csfg sfg sdf gsdfg sdfg sdfg d",
						Title = "Заголовок 1",
                        DateCreated = DateTime.Now
					},
					new MessageViewModel
					{
						From = "Вася",
                        To = "Петя",
						Message = page + "Исходящее 2сообщение csfg sfg sdf gsdfg sdfg sdfg d",
						Title = "Заголовок 2",
                        DateCreated = DateTime.Now
					}
				};
            return model;
        }

        [ActionName("reviews")]
        public IEnumerable<ReviewListViewModel> GetReviews(int page)
        {
            var model = new List<ReviewListViewModel>
                {
                    new ReviewListViewModel
                    {
                        Id = Guid.NewGuid(),
                        Description = "описание 222",
                        City = "Минск",
                        Price = 500,
                        Street = "Калиноскоого 64",
                        Status = ReviewStatus.Approved
                    },
                    new ReviewListViewModel
                    {
                        Id = Guid.NewGuid(),
                        Description = "описание 111",
                        City = "Минск",
                        Price = 1500,
                        Street = "Калиноскоого 64",
                        Status = ReviewStatus.Approved
                    },
                };
            return model;
        }

        [ActionName("comments")]
        public IEnumerable<CommentViewModel> GetComments(int page)
        {
            var model = new List<CommentViewModel>
                {
                    new CommentViewModel
                    {
                        From = "Петя",
                        Comment = "Коммент 1 csfg sfg sdf gsdfg sdfg sdfg d",
                        DateCreated = DateTime.Now
                    },
                    new CommentViewModel
                    {
                        From = "Вася",
                        Comment = "Коммент 2 sfg sdf gsdfg sdfg sdfg d",
                        DateCreated = DateTime.Now
                    }
                };
            return model;
        }

        [ActionName("notifications")]
        public IEnumerable<NotificationViewModel> GetNotifications(int page)
        {
            var model = new List<NotificationViewModel>
                {
                    new NotificationViewModel
                    {
                        Title = "Title 1",
                        Message = "NOtify 1 csfg sfg sdf gsdfg sdfg sdfg d",
                        DateCreated = DateTime.Now
                    },
                    new NotificationViewModel
                    {
                        Title = "Title 2",
                        Message = "Notify 2 sfg sdf gsdfg sdfg sdfg d",
                        DateCreated = DateTime.Now
                    }
                };
            return model;
        }
    }
}